package com.yubest.designpattern.behavior.mediator;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * 参与聊天的用户
 *
 * @Author: hweiyu
 * @Date: 2022/10/27 11:50
 */
@Data
@AllArgsConstructor
public class ChatUser {

    private String name;

    /**
     * 发送消息
     * @param mediator
     * @param msg
     */
    public void sendMsg(ChatRoomMediator mediator, String msg) {
        mediator.sendMsg(this, msg);
    }

    /**
     * 收到消息
     * @param msg
     */
    public void receiveMsg(String msg) {
        System.out.println(String.format("%s看到群消息：%s", this.getName(), msg));
    }
}
